<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ChartDemo.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script language="javascript" type="text/javascript"  src="jscharts.js"></script>
	
  </head>
  
  <body>
<f:view>	Welcome to my application.<br> 
			Click on one to display the chart:<br>
			<h:form>
				Enter First Value for Line Chart: <h:inputText id="line1" ></h:inputText><br>
				Enter Second Value for Line Chart: <h:inputText id="line2" ></h:inputText><br>				
				<h:commandButton type="button" value="Line Chart" onclick="linechart()"></h:commandButton>
				<h:commandButton type="button" value="Bar Chart" onclick="barchart()"></h:commandButton>
				<h:commandButton type="button" value="Bar Chart 2" onclick="barchart2()"></h:commandButton>
				<h:commandButton type="button" value="Pie Chart" onclick="piechart()"></h:commandButton>
			
			<div id="chartcontainer">
			<script type="text/javascript">
			function linechart()
			{
				var myData = new Array([10, 20], [13, 10], [16, 30], [19, 10], [22, 5],[25, 10], [28, 37], [31, 10], [34, 5]);
				var myChart = new JSChart('chartcontainer', 'line');
				myChart.setDataArray(myData);
				myChart.draw();
			}
			function barchart()
			{
				var myData = new Array(['unit', 20], ['unit two', 10], ['unit three', 30], ['other unit', 10], ['last unit', 30]);
				var myChart = new JSChart('chartcontainer', 'bar');
				myChart.setDataArray(myData);
				myChart.setAxisNameX('Horizontal axis values');
				myChart.setAxisNameY('Vertical axis');
				myChart.setBarColor('#42aBdB');
				myChart.setBarOpacity(0.8);
				myChart.setBarBorderColor('#D9EDF7');
				myChart.setBarValues(true);
				myChart.setTitleColor('#8C8383');
				myChart.setAxisColor('#777E81');
				myChart.setAxisValuesColor('#777E81');
				myChart.draw();
			}
			function barchart2()
			{
				var myChart = new JSChart('chartcontainer', 'bar');
				myChart.setDataXML("barData.xml");
				myChart.draw();
			}
			function piechart()
			{
				var myChart = new JSChart('chartcontainer', 'pie');
				myChart.setDataXML("data.xml");
				myChart.draw();
			}
			</script>
			</div>
  		</h:form>
  </f:view>
  
  </body>
</html>
